#pragma once

#include "UMLBehaviorDiagram.h"

#include "../uml/Behavior.h"

namespace uml {

void UMLBehaviorDiagram::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    PartialElement::fromJson(json, errorList);
    modelElement_ = JsonSerializable::create<Behavior>(json.value("modelElement"), errorList);

}

void UMLBehaviorDiagram::toJson(QJsonObject& json) {
    PartialElement::toJson(json);
    if (modelElement_) {
        QJsonObject modelElement_json;
        modelElement_->toJson(modelElement_json);
        json.insert("modelElement", modelElement_json);
    }
}

/// <summary>
/// modelElement getter
/// Restricts UMLBehaviorDiagrams to showing Behaviors.
/// </summary>
shared_ptr<Behavior> UMLBehaviorDiagram::modelElement() const {
    return modelElement_;
}

/// <summary>
/// modelElement setter
/// Restricts UMLBehaviorDiagrams to showing Behaviors.
/// </summary>
void UMLBehaviorDiagram::setModelElement(shared_ptr<Behavior> value) {
    modelElement_ = value;
}

} // namespace uml
